<div class="content-wrapper">
    <section class="content-header">
        <h1>订单详情</h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">订单管理</li>
            <li class="active">订单详情</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#order" data-toggle="tab">订单信息</a></li>
                        <li><a href="#goods" data-toggle="tab">订单商品</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="active tab-pane" id="order">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="box box-primary">
                                        <div class="box-body box-profile">
                                            <div class="col-md-6">
                                                <ul class="list-group list-group-unbordered">
                                                    <input type="hidden" class="order_id" id="order_id" value="{$orderInfo.order_id}"/>
                                                    <li class="list-group-item"><b>订单ID</b> <span class="pull-right">{$orderInfo.order_id}</span></li>
                                                    <li class="list-group-item"><b>订单编号</b> <span class="pull-right">{$orderInfo.order_code}</span></li>
                                                    <li class="list-group-item"><b>公司</b> <span class="pull-right">{$orderInfo.company_name}</span></li>
                                                    <li class="list-group-item"><b>联系人</b> <span class="pull-right">{$orderInfo.name}</span></li>
                                                    <li class="list-group-item"><b>联系方式</b>
                                                        <div class="panel panel-info">
                                                            <table class="table">
                                                                <foreach name="orderInfo.contact_info" item="contact" key="k">
                                                                    <tr><td>{$k}</td><td>{$contact}</td></tr>
                                                                </foreach>
                                                            </table>
                                                        </div>
                                                    </li>
                                                    <li class="list-group-item"><b>推广产品/游戏</b> <span class="pull-right">{$orderInfo.product_name}</span></li>
                                                    <li class="list-group-item"><b>一级产品</b> <span class="pull-right">{$orderInfo.first_name}</span></li>
                                                    <li class="list-group-item"><b>业务员</b> <span class="pull-right">{$orderInfo.admin_name}</span></li>
                                                    <li class="list-group-item"><b>部门</b> <span class="pull-right">{$orderInfo.department_name}</span></li>
                                                    <li class="list-group-item"><b>下单时间</b> <span class="pull-right">{$orderInfo.create_time}</span></li>
                                                    <li class="list-group-item"><b>订单状态</b> <span class="pull-right">{$orderInfo.status_desc}</span></li>
                                                </ul>
                                            </div>
                                            <div class="col-md-6">
                                                <ul class="list-group list-group-unbordered">
                                                    <li class="list-group-item"><b>是否到账</b> <span class="pull-right">
                                                        <if condition="$orderInfo.is_pay eq 0">未到账<else />已到账</if>
                                                    </span></li>
                                                    <li class="list-group-item"><b>终端客户</b> <span class="pull-right">{$orderInfo.company_name}</span></li>
                                                    <li class="list-group-item"><b>账期</b> <span class="pull-right">{$orderInfo.pay_interval}个月</span></li>
                                                    <li class="list-group-item"><b>公司名（代理商）</b> <span class="pull-right">{$orderInfo.agent_name}</span></li>
                                                    <li class="list-group-item"><b>渠道公司</b> <span class="pull-right">{$orderInfo.ditch_company}</span></li>
                                                    <li class="list-group-item"><b>销售金额</b> <span class="pull-right">{$orderInfo.amount}</span></li>
                                                    <li class="list-group-item"><b>报价</b> <span class="pull-right">{$orderInfo.quoted_price}</span></li>
                                                    <li class="list-group-item"><b>毛利</b> <span class="pull-right">{$orderInfo.profit_price}</span></li>
                                                    <li class="list-group-item"><b>其他费用</b> <span class="pull-right">{$orderInfo.other_price}</span></li>
													<li class="list-group-item"><b>合同文件</b> 
													<span class="pull-right">
													<php>if($orderInfo['order_bill']['contract']){</php>
														<a href='{$orderInfo.order_bill.contract}' target="_blank">预览</a>
													<php>}else{</php>
														暂无
													<php>}</php>
													</span>
													</li>
													<li class="list-group-item"><b>发票文件</b>
													<span class="pull-right">
													<php>if($orderInfo['order_bill']['bill']){</php>
														<a href='{$orderInfo.order_bill.bill}' target="_blank">预览</a>
													</span>
													<php>}else{</php>
														暂无
													<php>}</php>
													</span>
													</li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="goods">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="box box-primary">
                                        <div class="box-body">
                                            <table class="table table-bordered">
                                                <thead>
                                                <th>产品名称</th>
                                                <th>报价类型</th>
                                                <th>广告主</th>
                                                <th>推广产品</th>
                                                <th>所属行业</th>
                                                <th>投放端&位置</th>
                                                <th>投放广告位</th>
                                                <th>投放吧</th>
                                                <th>投放时间</th>
                                                <th>报价</th>
                                                <th>报价详情</th>
                                                </thead>
                                                <tbody id="itemList-b">
                                                <if condition="count($orderInfo.itemList) eq 0 "><tr><td colspan="11">暂未添加</td></tr></if>
                                                <foreach name="orderInfo.itemList" item="item" key="key">
                                                    <tr>
                                                        <td>{$item.first_name}-{$item.second_name}-{$item.item_name}</td>
                                                        <td>
                                                            <if condition="$item.quoted_type eq 1 ">
                                                                <span class="label label-success">预估报价</span>
                                                                <elseif condition="$item.quoted_type eq 2" />
                                                                <span class="label label-info">百度询价</span>
                                                                <else />
                                                                <span class="label label-default">不询价</span>
                                                            </if>

                                                        </td>
                                                        <td>{$item.advertiser}</td>
                                                        <td>{$item.promote_product}</td>
                                                        <td>{$item.trade}</td>
                                                        <td>{$item.port}</td>
                                                        <td>{$item.place}</td>
                                                        <td>{$item.post_bar}</td>
                                                        <td>{$item.put_time}</td>
                                                        <td>{$item.total_price}</td>
                                                        <td>
                                                            <if condition="$item.quoted_file neq ''">
                                                                <a type="button" class="btn btn-sm btn-primary" href="/admin/index/downloadFile?file={$item.quoted_file|urlencode}"><i class="fa fa-cloud-download"></i>详情</a>
                                                                <else />
                                                                <label class="label label-default">暂未上传</label>
                                                            </if>
                                                        </td>
                                                    </tr>
                                                </foreach>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <php>if($orderInfo['status']<55 && $orderInfo['status']>=45){</php>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="form-field-1" class="col-sm-5 control-label"></label>
                                        <div class="col-sm-5">
                                            <button class="btn btn-primary btn-sm btn-accept-order" type="button" data-id="{$orderInfo.order_id}">受理</button>&nbsp;
                                            <button class="btn btn-warning btn-sm btn-refuse-order" type="button" data-id="{$orderInfo.order_id}" data-toggle="modal" data-target="#refuseSystemModalLabel">拒绝</button>&nbsp;
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <php>}</php>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="refuseSystemModalLabel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="margin-top: 200px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">拒绝备注</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form" action="javascrip:;" method="post">
                    <div class="form-group">
                        <input type="hidden" name="order_id" id="refuse_order_id">
                    </div>
                   
                    <div class="form-group">
                        <div class="col-sm-12">
                            <textarea type="text" class="form-control" placeholder="拒绝备注" id="description" name="description" rows="5"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="do-refuse">确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<script src="__PUBLIC__/AdminLTE/plugins/layer/layer.js"></script>
<script type="application/javascript">
    $(function () {
        $(".btn-accept-order").click(function () {
            var order_id = $(this).attr('data-id');
            ArtDialogHlp.showConfirm('提示','确认受理该订单？',function () {
                    $.post('/admin/order/ajaxCheckOrderStatus',{
                        order_id: order_id
                    },function (_data) {
                        if(_data.Code==999){
                            layer.msg("订单受理成功",{time:1000});
                            window.location.href = '/admin/order/acceptOrder?id=' + order_id;
                        }else if(_data.Code==300){
                            layer.msg(_data.Msg,{time:1000});
                            window.location.href = '/admin/order/orderList';
                        }else {
                            ArtDialogHlp.showInfo('提示',_data.Msg);
                            return false;
                        }

                    },"JSON");
                }
            );
        });
        //拒绝
        $(".btn-refuse-order").click(function () {
            var order_id = $(this).attr('data-id');
            $('#refuse_order_id').val(order_id);
        });
        //确认拒绝
        $('#do-refuse').click(function () {
            var order_id = $('#refuse_order_id').val();
            var description = $('#description').val();

            if(order_id == ''){
                layer.msg('参数错误',{time:1000});
                return false;
            }
            $('#refuseSystemModalLabel').modal('hide');
            //ajax提交拒绝备注
            $.post('/admin/order/ajaxRefuseAcceptOrder', {
                order_id: order_id,
                refuse_accept_reason: description
            }, function (_data) {
                if (_data.Code == 999) {
                    layer.alert('操作成功', {
                        skin: 'layui-layer-molv' //样式类名
                        ,closeBtn: 0
                    }, function(){
                        window.location.href = '/admin/order/yzWaitAcceptOrderList';
                    });
                } else if (_data.Code == 300) {
                    layer.alert(_data.Msg, {
                        skin: 'layui-layer-molv' //样式类名
                        ,closeBtn: 0
                    }, function(){
                        window.location.href = '/admin/order/orderList';
                    });
                } else {
                    layer.alert(_data.Msg, {
                        skin: 'layui-layer-molv' //样式类名
                        ,closeBtn: 0
                    });
                    return false;
                }
            }, "JSON");
        });
    });
</script>